package com.lixh.virtual.app;

import android.content.Context;

import com.lixh.app.BaseApplication;
import com.lixh.utils.ULog;
import com.lixh.virtual.app.os.AppRepository;
import com.lixh.virtual.app.os.delegate.MyVirtualInitializer;
import com.lody.virtual.client.core.VirtualCore;
import com.lody.virtual.client.stub.VASettings;

/**
 * Created by LIXH on 2019/4/22.
 * email lixhVip9@163.com
 * des
 */
public class AppContext extends BaseApplication {

    VirtualCore virtualCore;
    private static AppContext instance;

    @Override
    public void init() {
        instance = this;
        virtualCore = VirtualCore.get();
        virtualCore.initialize(new MyVirtualInitializer(this, virtualCore));
        AppRepository.init(this);
        ULog.logInit(true);

    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        VASettings.ENABLE_IO_REDIRECT = true;
        VASettings.ENABLE_INNER_SHORTCUT = false;
        try {
            VirtualCore.get().startup(base);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    public static AppContext getInstance() {
        return instance;
    }

}
